import {
	inputComponents,
	layoutComponents,
	selectComponents
} from "@/views/flow/createDirectly/generatorForm/config.js";
import {G} from "@/views/flow/globalVar.js";
import publicWork from "@/views/flow/createDirectly/generatorForm/customMadeComponents/publicWork.js";
export const copyConfigAsCustom = (rowConf,
                                   childrenConf) => {
	const clone = (target,
	               conf = {}) => {
		const template = JSON.parse(JSON.stringify(target))
		return Object.assign({},
			template,
			{cmpType: 'custom'},
			conf)
	}
	const defaultRow = clone(layoutComponents[0],
		rowConf)
	defaultRow.children = childrenConf.map(t => clone(t.target,
		t.config))
	return defaultRow
}
export const getConfigByTag = (targetList,
                               tag) => {
	return targetList.find(t => t.tag === tag)
}
export const customMadeComponents = [publicWork({
	copyConfigAsCustom,
	getConfigByTag
}),]
